require(["common", "coAjax"], function(jSouper, coAjax) {
	App.set("$Event.user.changepwd.change", function(e, vm) {
		var current_pwd = App.get("$Cache.user.changepwd.current_pwd");
		var new_pwd = App.get("$Cache.user.changepwd.new_pwd");
		var new_pwd_bak = App.get("$Cache.user.changepwd.new_pwd_bak");
		if (!current_pwd) {
			alert("warn", "请输入当前密码");
			return;
		};
		if (new_pwd !== new_pwd_bak) {
			alert("warn", "两次密码不匹配");
			return;
		};
		coAjax.put(appConfig.user.change_password, {
			old_password: current_pwd,
			new_password: new_pwd
		}, function(result) {
			App.set("$Cache.user.changepwd.current_pwd", "");
			App.set("$Cache.user.changepwd.new_pwd", "");
			App.set("$Cache.user.changepwd.new_pwd_bak", "");
			alert("success", "密码修改成功");
		}, function(errorCode, xhr, errorMsg) {
			alert("error", errorMsg);
		});
	});
});